﻿-- Define the relationship between Activity and Model
ALTER TABLE [dbo].[Activity] WITH CHECK ADD  
       CONSTRAINT [FK_Activity_Model] FOREIGN KEY([Model])
REFERENCES [dbo].[Model] ([ModelId])
ON DELETE NO ACTION
GO
-- Define the relationship between Activity and Person
ALTER TABLE [dbo].[Activity] WITH CHECK ADD  
       CONSTRAINT [FK_Activity_CreatedByPerson] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between Activity and Category
ALTER TABLE [dbo].[Activity] WITH CHECK ADD  
       CONSTRAINT [FK_Activity_Category] FOREIGN KEY([Category])
REFERENCES [dbo].[Category] ([CategoryId])
ON DELETE NO ACTION
GO
-- Define the relationship between Activity and Person
ALTER TABLE [dbo].[Activity] WITH CHECK ADD  
       CONSTRAINT [FK_Activity_Person] FOREIGN KEY([ResponsiblePerson])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between Activity and Person
ALTER TABLE [dbo].[Activity] WITH CHECK ADD  
       CONSTRAINT [FK_Activity_LastChangedBy] FOREIGN KEY([LastChangedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO